#pragma once

#include "Protocol.hpp"

struct Calculate
{
    Response Execute(Request &request)
    {
        switch (request.getOption())
        {
        case '+':
            return Response(request.getX() + request.getY(), 0);
        case '-':
            return Response(request.getX() - request.getY(), 0);
        case '*':
            return Response(request.getX() * request.getY(), 0);
        case '/':
        {
            if (0 == request.getY())
                return Response(0, 1);
            else
                return Response(request.getX() / request.getY(), 0);
        }
        default:
            return Response(0, 2);
        }
    }
};
